<?php
require('../../../lib/base.php');
$base=new base('web');
$id=intval($base->get('id'));
$data['menu']=$base->cache(array('tag'=>'web.header','time'=>86400));
$data['menu']=unserialize($data['menu']);
$data['foot']=$base->cache(array('tag'=>'web.footer','time'=>86400));
$content=$base->model('content');
if($id!==0){
	$data['publish']=reset($content->GContent(array('where'=>array('id='=>$id))));
	$base->set($data);
	$base->view('view/content.php');
}else{
	$pams=array('order'=>array('sequence'=>'DESC','date'=>'DESC'),'limit'=>array(intval($base->get('start')),15));
	$data['sort']=$base->get('sort');
	if($data['sort']!=false){
		$pams['where']['sort=']=intval($data['sort']);
	}
	$data['total']=$content->GContent(array('select'=>'COUNT(*) AS count','where'=>$pams['where']));
	$data['total']=empty($data['total'])?0:$data['total'][0]['count'];
	$data['publish']=$content->GContent($pams);
	$pagination=$base->library('pagination',array('base_url'=>domain.'view/publish.php?','total_rows'=>$data['total'],'per_page'=>15,'first_link'=>'首页','last_link'=>'末页','cur_tag_open'=>'<a href="#" class="active">','cur_tag_close'=>'</a>'));
	$data['pagination']=$pagination->create_links();
	$base->set($data);
	$base->view('view/publish.php');
}
?>